import _ from 'lodash'

export default {
  props: {
    collectProps: {
      type: Object,
      default: () => ({
        type: 'choice',
        fill: 'fill',
      }),
    },
  },

  computed: {
    infoValue () {
      const index = _.findIndex(
        this.option,
        ({ field_value: fv, field_label: fl }) => fv === this.inputValue || fl === this.inputValue,
      )

      const { fill_value } = this.option[index] || {}
      console.log(fill_value, 'indexindex')
      return fill_value || ''
    },

    // 信息收集
    collectInfo () {
      if (!this.value || this.can_do) return null
      const { type, fill } = this.collectProps

      return {
        field: this.id,
        field_value: {
          [type]: this.inputValue || '',
          [fill]: this.infoValue,
        },
      }
    },
  },
}
